import modelEntity from "./modelEntity";
export default class PersonnelInfo extends modelEntity {
  constructor(options) {
    super(options);
    this.Name = options.Name;
    this.Post = options.Post;
    this.UnitID = options.UnitID;
    this.MobilePhone = options.MobilePhone;
    this.WeChat = options.WeChat;
    this.Telephone = options.Telephone;
    this.EMail = options.EMail;
    this.Remark = options.Remark;
    this.Department = options.Department;
  }
  static newInstance() {
    return new PersonnelInfo({
      Name: null,
      Post: null,
      MobilePhone: null,
      WeChat: null,
      Telephone: null,
      EMail: null,
      Remark: null,
      Department: null,
    })
  }
  static loadList() {
    return new Promise((resolve, reject) => {
      getApp().globalData.api.http_get(`${getApp().globalData.baseUrl}/api/sys/personalinfo`)
        .then(
          res => {
            console.log(res);
            let list = [];
            res.forEach(x => {
              list.push(new PersonnelInfo(x));
            });
            resolve(list);
          }
        )
    })
  }
  create() {
    return new Promise((resolve, reject) => {
      window.api.http_post("/api/sys/personalinfo", this)
        .then(
          res => {
            let model = new PersonnelInfo(res);
            resolve(model);
          }
        )
    })
  }
  delete() {
    return new Promise((resolve, reject) => {
      window.api.http_delete("/api/sys/personalinfo", this)
        .then(
          res => {
            resolve(res);
          }
        )
    })
  }
  modify() {
    return new Promise((resolve, reject) => {
      window.api.http_put("/api/sys/personalinfo", this)
        .then(
          res => {
            let model = new PersonnelInfo(res);
            resolve(model);
          }
        )
    })
  }
}
